package com.ququ.syb.transferorder.controller;

import com.ququ.common.result.Result;
import com.ququ.syb.common.pojo.TransferOrder;
import com.ququ.syb.transferorder.service.TransferOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class TransferOrderController {
    @Autowired
    private TransferOrderService transferOrderService;

    @RequestMapping("/query")
    public Result<TransferOrder> getTransferOrder(@RequestParam String tradenum){
        TransferOrder transferOrder = transferOrderService.getTransferOrder(tradenum);
        if (transferOrder == null)
            return new Result<>(-1,"查无此转账订单记录");
        else
            return new Result<>(transferOrder);
    }


    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public Result<TransferOrder> saveTransferOrder(@RequestBody TransferOrder transferOrder){
        transferOrder = transferOrderService.save(transferOrder);
        return new Result<>(transferOrder);
    }


    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Result<TransferOrder> updateTransferOrder(@RequestBody TransferOrder transferOrder){
        transferOrder = transferOrderService.update(transferOrder);
        return new Result<>(transferOrder);
    }

}
